from UIAutoTest.shop_test.pom.BasePage import BasePage
from selenium.webdriver.common.by import By
import time


# 购物车模块
class ShopCarPage(BasePage):
    # 元素定位
    onePage = (By.XPATH, '//*[@id="doc-topbar-collapse"]/ul/li[1]/a')
    huawei = (By.XPATH, '//*[@id="floor1"]/div[2]/div[2]/div[5]/a')
    addShopCar = (By.XPATH, '//div[@class="buy-submit-container buy-submit-container-number-2"]//button[2]')
    clickShopCar =(By.XPATH,'//*[@class="am-container header"]//span[text()=\'购物车\']')

    def add_ShopCar(self):
        self.click(self.onePage)
        time.sleep(1)
        self.scrollTo()
        time.sleep(1)
        self.click(self.huawei)
        time.sleep(1)
        self.switch_to()
        time.sleep(1)
        self.click(self.addShopCar)
        time.sleep(1)
        self.click(self.clickShopCar)




